package net.kingborn.erp.wc.command;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import net.kingborn.core.command.BaseCommand;
import net.kingborn.core.command.Command;
import net.kingborn.core.command.Param;
import net.kingborn.erp.wc.model.Attendance;
import net.kingborn.erp.wc.service.AttendanceService;
import org.springframework.beans.factory.annotation.Autowired;

@Command
public class AttendanceSave extends BaseCommand {


    @Param(required = true)
    private JSONArray list;

    @Autowired
    AttendanceService attendanceService;

    @Override
    protected void init() throws Exception {

    }

    @Override
    protected void doCommand() throws Exception {

        System.out.println(list);
        for (Object obj : list) {
            Attendance attendance = JSON.toJavaObject((JSON) obj, Attendance.class);
            attendanceService.saveInfo(attendance);
        }

    }
}
